/*
 *     This file is part of Mobile GPS Logger.
 * 
 *     Mobile GPS Logger is free software: you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation, either version 3 of the
 *     License, or (at your option) any later version.
 * 
 *     Mobile GPS Logger is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License v3 for more details.
 * 
 *     You should have received a copy of the GNU General Public License v3
 *     along with Mobile GPS Logger. If not, see <http://www.gnu.org/licenses/>.
 */

package cx.ath.skyflyer.gpslog.nmea;

import cx.ath.skyflyer.gpslog.util.M;

/**
 * This class contains functions to work with NMEA sentences or parts of them.
 * @author Ahti Legonkov
 */
public class NmeaUtils {

    /**
     * Converts degrees (as found in NMEA sentences) to radians.
     * @return given angle in radians.
     */
    public static double degreesToRadians(String nmeaDegrees) {

        double ds = Double.parseDouble(nmeaDegrees);
        double degrees = Math.floor(ds / 100.0);
        double minutes = ds - 100.0*degrees;
        return (degrees + minutes / 60.0) * M.PI_OVER_180;
    }
}
